package net.asfun.jvalog.misc;

import net.asfun.jvalog.domain.Blog;

public class Setting {

	public static String root;
	public static String errorPage = "<center><h1>System Error</h1></center>";
	
	private static int timezone = 100;
	private static int rssSize = 0;
	private static int atomSize = 0;
	private static int mapSize = 0;
	private static int pageSize = 0;
	private static int recentPosts = 0;
	private static int recentComments = 0;
	
	public static void reset() {
		timezone = 100;
		rssSize = 0;
		atomSize = 0;
		mapSize = 0;
		pageSize = 0;
		recentPosts = 0;
		recentComments = 0;
	}
	
	public static String getTimezone() {
		if ( timezone == 100 ) {
			timezone = Blog.getTimezone();
		}
		if ( timezone > 12 || timezone < -12) {
			timezone = 8;
		}
		if ( timezone > 0 ) {
			return "GMT+" + timezone;
		} else {
			return "GMT" + timezone;
		}
	}
	
	public static int getRssSize() {
		if ( rssSize == 0 ) {
			rssSize = Blog.getRssSize();
		}
		return rssSize;
	}
	
	public static int getPageSize() {
		if ( pageSize == 0 ) {
			pageSize = Blog.getPageSize();
		}
		return pageSize;
	}
	
	public static int getAtomSize() {
		if ( atomSize == 0 ) {
			atomSize = Blog.getAtomSize();
		}
		return atomSize;
	}
	
	public static int getMapSize() {
		if ( mapSize == 0 ) {
			mapSize = Blog.getMapSize();
		}
		return mapSize;
	}
	
	public static int getRecentPosts() {
		if ( recentPosts == 0 ) {
			recentPosts = Blog.getRecentPosts();
		}
		return recentPosts;
	}
	
	public static int getRecentComments() {
		if ( recentComments == 0 ) {
			recentComments = Blog.getRecentComms();
		}
		return recentComments;
	}

}
